/*
 * NetworkSettingsImpl.java
 *
 * Copyright 2007, 2008 Tiberiumlabs
 *
 * This file is part of Tiberiumlabs Lailaps.
 *
 * Tiberiumlabs Lailaps is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Tiberiumlabs Lailaps is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.tiberiumlabs.lailaps.settings;

import java.nio.charset.Charset;
import java.util.ArrayList;
import org.tiberiumlabs.lailaps.toolkit.Constants;

/**
 * @author <a href="mailto:paranoid.tiberiumlabs@gmail.com">Paranoid</a>
 */
public class NetworkSettingsImpl implements NetworkSettings {
    
    private static final String EMPTY_STRING = "";
    
    // General settings variables
    private int downloadBufferSize = 4096;
    private int maxWorkingThreads = 2;
    private int maxSegmentsPerThread = 2;
    private ArrayList<String> charsetList = new ArrayList(1);
    
    // HTTP settings variables
    private String userAgent = DEFAULT_USER_AGENT;
    private boolean useCustomAgent = false;
    private int httpTimeout = 30000;
    
    // FTP Settings variables
    private int ftpModeType = Constants.FTP_MODE_PASSIVE;
    private int ftpTransferType = Constants.FTP_TRANSFER_BINARY;
    private boolean ftpTcpNoDelay = true;
    private int ftpDataTimeout = 30000;
    
    // Proxy settings variables
    private boolean proxyEnabled = false;
    private int proxyType = Constants.PROXY_TYPE_HTTP;
    private String proxyHost = EMPTY_STRING;
    private int proxyPort = 0;
    private String noProxyFor = "localhost, 127.0.0.1";
    private boolean proxyNeedAuthorization = false;
    private String proxyLogin = EMPTY_STRING;
    private String proxyPassword = EMPTY_STRING;

    public NetworkSettingsImpl() {
      charsetList.add(Charset.defaultCharset().name());
    }
      
    // <editor-fold defaultstate="collapsed" desc=" General settings ">
    
    public int getDownloadBufferSize() {
        return downloadBufferSize;
    }
    
    public void setDownloadBufferSize(int downloadBufferSize) {
        this.downloadBufferSize = downloadBufferSize;
    }
    
    public int getMaxWorkingThreads() {
        return maxWorkingThreads;
    }
    
    public void setMaxWorkingThreads(int maxWorkingThreads) {
        this.maxWorkingThreads = maxWorkingThreads;
    }

    public int getMaxSegmentsPerThread() {
        return maxSegmentsPerThread;
    }

    public void setMaxSegmentsPerThread(int maxSegmentsPerThread) {
        this.maxSegmentsPerThread = maxSegmentsPerThread;
    }

    public ArrayList<String> getCharsetList() {
        return charsetList;
    }

    public void setCharsetList(ArrayList<String> charsetList) {
        this.charsetList = charsetList;
    }
      
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc=" HTTP settings ">
    
    public String getUserAgent() {
        return userAgent;
    }
    
    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }
    
    public boolean isUseCustomAgent() {
        return useCustomAgent;
    }
    
    public void setUseCustomAgent(boolean useCustomAgent) {
        this.useCustomAgent = useCustomAgent;
    }
    
    public int getHttpTimeout() {
        return httpTimeout;
    }
    
    public void setHttpTimeout(int httpTimeout) {
        this.httpTimeout = httpTimeout;
    }
    
    //</editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc=" FTP settings ">
    
    public int getFtpModeType() {
        return ftpModeType;
    }
    
    public void setFtpModeType(int ftpModeType) {
        this.ftpModeType = ftpModeType;
    }
    
    public int getFtpTransferType() {
        return ftpTransferType;
    }
    
    public void setFtpTransferType(int ftpTransferType) {
        this.ftpTransferType = ftpTransferType;
    }
    
    public boolean isFtpTcpNoDelay() {
        return ftpTcpNoDelay;
    }
    
    public void setFtpTcpNoDelay(boolean ftpTcpNoDelay) {
        this.ftpTcpNoDelay = ftpTcpNoDelay;
    }
    
    public int getFtpDataTimeout() {
        return ftpDataTimeout;
    }
    
    public void setFtpDataTimeout(int ftpDataTimeout) {
        this.ftpDataTimeout = ftpDataTimeout;
    }
    
    //</editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc=" Proxy settings methods">
    
    public boolean isProxyEnabled() {
        return proxyEnabled;
    }
    
    public void setProxyEnabled(boolean proxyEnabled) {
        this.proxyEnabled = proxyEnabled;
    }
    
    public int getProxyType() {
        return proxyType;
    }
    
    public void setProxyType(int proxyType) {
        this.proxyType = proxyType;
    }
    
    public String getProxyHost() {
        return proxyHost;
    }
    
    public void setProxyHost(String proxyHost) {
        this.proxyHost = proxyHost;
    }
    
    public int getProxyPort() {
        return proxyPort;
    }
    
    public void setProxyPort(int proxyPort) {
        this.proxyPort = proxyPort;
    }
    
    public String getNoProxyFor() {
        return noProxyFor;
    }
    
    public void setNoProxyFor(String noProxyFor) {
        this.noProxyFor = noProxyFor;
    }
    
    public boolean isProxyNeedAuthorization() {
        return proxyNeedAuthorization;
    }
    
    public void setProxyNeedAuthorization(boolean proxyNeedAuthorization) {
        this.proxyNeedAuthorization = proxyNeedAuthorization;
    }
    
    public String getProxyLogin() {
        return proxyLogin;
    }
    
    public void setProxyLogin(String proxyLogin) {
        this.proxyLogin = proxyLogin;
    }
    
    public String getProxyPassword() {
        return proxyPassword;
    }
    
    public void setProxyPassword(String proxyPassword) {
        this.proxyPassword = proxyPassword;
    }
    
    //</editor-fold>
    
}
